Skip to content

Conversation

jpstotz
Copy link

@jpstotz jpstotz commented Nov 28, 2024

In Java System.currentTimeMillis() returns the time of the system real-time clock which can change at any time, e.g. if your NTP client adjusts it. If this happens while a diff is running the timeout may increase or decrease in an undeterministic way.

For this reason time calculation in Java should always use System.nanoTime() which usually bases on the monotonic increasing tick counter of the CPU (see System.nanoTime() JavaDoc)

The other edits are just minor code clean-up.

@dmsnell
Copy link
Owner

dmsnell commented Oct 14, 2025

@jpstotz for brevity’s sake would you mind stripping away the other edits? if not, I should be able to prune them out and merge the timer update.

@jpstotz
Copy link
Author

jpstotz commented Oct 15, 2025

@dmsnell I have updated my PR

dmsnell pushed a commit that referenced this pull request Oct 15, 2025
…ck. (#15)

Previously the timeout was compared against the system clock, which is
prone to skew and unexpected changes. With this patch the comparison is
made against `System.nanoTime()` which is a high-precision monotically
increasing time designed for elapsed time measurements. This isolates
the timeout from system variation.
@dmsnell
Copy link
Owner

dmsnell commented Oct 15, 2025

@jpstotz thanks! I merged this into main in c32b811

Would have merged this PR as written, but I wanted to add a note in the CHANGELOG. Not sure how I’ll do versioning yet, but this is in the main trunk so hopefully you can update and verify that it’s working now.

@dmsnell dmsnell closed this Oct 15, 2025
dmsnell added a commit that referenced this pull request Oct 15, 2025
Previously the `prettyHtml` functions made some changes to diff content
to better represent special characters, but not exhaustively. For
instance, it escapes `<` as `&lt;` so that the HTML preview interprets
the content as plaintext and not as HTML. Similarly, it replaces the
LINE FEED character with `&para;<br>` so that when interpreted by a
browser, the HTML will visually correspond to the newline (whereas HTML
parsers would normalize the whitespace and not show an actual newline).

This patch extends the existing transformation to represent horizontal
tabs with an `&emsp;` EM SPACE and a space character with `&nbsp;` to
further highlight changes to these whitespace characters, rather than
having them blend in via whitespace normalization.

Co-authored-by: Dennis Snell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants